#include <vector>
#include <iostream>

using namespace std;

class Solution 
{
public:
    void rotate(vector<vector<int> > &matrix)
	{
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
		size_t n = matrix.size();
		if(n<=1)
			return;

		for(size_t i=1;i<=(n/2);i++)
		{
			for(size_t j=i;j<(n-i+1);j++)
			{
				int tmp = matrix[i-1][j-1];
				matrix[i-1][j-1] = matrix[n-j][i-1];
				matrix[n-j][i-1] = matrix[n-i][n-j];
				matrix[n-i][n-j] = matrix[j-1][n-i];
				matrix[j-1][n-i] = tmp;
			}
		}

    }
};

int main()
{
	int n;
	Solution s;
	while(cin>>n)
	{
		if(n==0)
			break;

		vector<vector<int> > matrix(n);
		for(int i=0;i<n;i++)
		{
			matrix[i] = vector<int>(n);
			for(int j=0;j<n;j++)
			{
				cin>>matrix[i][j];
			}
		}

		s.rotate(matrix);

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				cout<<matrix[i][j]<<" ";
			}
			cout<<endl;
		}
	}
}
